<template>
  <div class='meetings-records'>
    <Table :modelData="modelData" :listData="listData" :pageInfo="pageInfo"></Table>
  </div>
</template>
<script>
import Table from "../../../components/table";
export default {
  components: { Table },
  name: "",
  data() {
    return {
      modelData: [
        { myType: "index", label: "序号" },
        { myType: "normal", prop: "name", label: "名称" },
        { myType: "normal", prop: "timeStr", label: "时间" },
        { myType: "normal", prop: "state_no", label: "状态" },
        {
          myType: "operate",
          label: "管理",
          btns3:[
            {
              label: "停止",
              click: this.stop,
              icon: require("../../../assets/images/manageMeetings/stop.png")
            }
          ],
          btns2: [
            {
              label: "编辑",
              click: this.edit,
              icon: require("../../../assets/images/manageHome/edit.png")
            },
            {
              label: "开启",
              click: this.start,
              icon: require("../../../assets/images/manageMeetings/start.png")
            },
          ],
          btns:[
            {
              label: "查看",
              click: this.look,
              icon: require("../../../assets/images/manageMeetings/watch.png")
            },{
              label: "删除",
              click: this.delete,
              icon: require("../../../assets/images/manageIssues/delete.png")
            }
          ],
          width: "180"
        }
      ],
      listData: [],
      pageInfo: {
        page: 1,
        total: 10,
        size: 10,
        changePage: this.changePage
      }
    };
  },
  methods: {
    // 开启
    start(scope){
      _g.apiPost('meeting/start.do',{id:scope.row.id}).then(res=>{
        _g.toMessage(res)
        if(!res.status){
          this.getListData()
        }
      })
    },

    // 停止
    stop(scope){
      _g.apiPost('meeting/closeMeeting.do',{id:scope.row.id}).then(res=>{
        _g.toMessage(res)
        if(!res.status){
          this.getListData()
        }
      })
    },
    // 编辑
    edit(scope) {
      this.$router.push('/manageMeetings/records/edit/'+scope.row.id)
    },
    
    // 查看
    look(scope){
      this.$router.push('/manageMeetings/records/look/'+scope.row.id)
    },

    // 删除
    delete(scope){
      _g.apiPost('meeting/delete.do',{id:scope.row.id}).then(res=>{
        _g.toMessage(res)
        if(!res.status){
          this.getListData()
        }
      })
    },

    changePage() {this.getListData()},
    getListData(){
      var params={
        currPageNo:this.pageInfo.page
      }
      _g.apiPost('meeting/getMeetingList.do',params).then(res=>{
        this.pageInfo.total=res.data.total
        res.data.list.forEach(ele => {
          ele.state_no=ele.status==0?'未开启 ':ele.status==1?'进行中':'已结束'
        });
        
        this.$set(this,'listData',res.data.list)
      })
    }

  },
  
  created() {this.getListData()}
};
</script>
<style lang="scss" scoped>
.meetings-records {
  height: 100%;
}
</style>